export default function translation(file) {
    const url =
        'https://southeastasia.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15';
    return new Promise((resolve, reject) => {
        uni.uploadFile({
            url: url,
            method: 'POST',
            header: {
                'Ocp-Apim-Subscription-Key':
                    '7pNaFVFn40XX4hT2Yq4VyzeCWVBnsDFbO2FbR3UqCZINsok3Q6GoJQQJ99BCACqBBLyXJ3w3AAAYACOGl8vt',
            },
            // #ifdef MP-WEIXIN || APP-PLUS
            filePath: file.tempFilePath,
            // #endif
            // #ifdef H5
            file: file.blob,
            // #endif
            name: 'audio',
            success: res => {
                if (res.statusCode === 200) {
                    resolve(JSON.parse(res.data));
                } else {
                    reject(JSON.parse(res.data));
                }
            },
            fail: err => {
                reject(err);
            },
        });
    });
}
